package com.wh.blockquene;
/**
 * 
 *  Class Name: TestWaitAndNotify7.java
 *  Description: 只有被锁的那个对象才能调用wait方法，没有持有
 *  @author wanghao  DateTime 2016年12月5日 下午6:18:44 
 *  @company hongbo
 *  @email 1228675455@qq.com
 */
public class TestWaitAndNotify7 extends Thread{

	private Object o;
	
	public TestWaitAndNotify7(Object o) {
		this.o = o;
	}
	
	@Override
	public void run() {
		
		synchronized (o) {
			try {
				System.out.println("进入等待-----------");
				o.wait();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
	
	public static void main(String[] args) {
		Object o = new Object();
		Thread thread = new TestWaitAndNotify7(o);
		thread.start();
		Thread thread1 = new TestWaitAndNotify7(o);
		thread1.start();
	}
	
}
